//
//  ADJgSDKRewardVodAdContainer.m
//  AnyThinkSDKDemo
//
//  Created by 刘娟 on 2024/9/24.
//  Copyright © 2024 抽筋的灯. All rights reserved.
//

#import "ADJgSDKRewardVodAdContainer.h"


@interface ADJgSDKRewardVodAdContainer()<ADJgSDKRewardvodAdDelegate>

@property(nonatomic, strong) ADJgSDKRewardvodAd *rewardVodAd;

@property(nonatomic, assign) CGFloat bidPrice;
@end

@implementation ADJgSDKRewardVodAdContainer
-(void)setDelegate:(id<ADJgSDKRewardvodAdDelegate>)delegate{
    self.rewardVodAd.delegate = delegate;
}
// MARK: - Init
-(instancetype)initPosId:(NSString *)posId delegate:(id<ADJgSDKRewardvodAdDelegate>)delegate{
    self = [super init];
    if(self){
        self.rewardVodAd = [ADJgSDKRewardvodAd new];
        self.rewardVodAd.posId = posId;
        self.rewardVodAd.delegate = delegate;
        if (delegate == nil) {
            self.rewardVodAd.delegate = self;
        }
    }
    return self;
}
- (void)loadRewardVodAd{
    if(self.rewardVodAd){
        [self.rewardVodAd loadRewardvodAd];
    }
}
- (void)showRewardVodAdWithRootViewController:(UIViewController *)controller{
    _rewardVodAd.controller = controller;
    [_rewardVodAd showRewardvodAd];
}

-(void)close{
    _rewardVodAd = nil;
}
- (NSInteger)getBidPrice{
   
    return _bidPrice;
}
#pragma mark -- JgAdsRewardVodAdDelegate
/**
 *  开屏广告素材加载成功
 */
- (void)adjg_rewardvodAdLoadSuccess:(nonnull ADJgSDKRewardvodAd *)rewardvodAd {
#if DEBUG
        NSLog(@"ADJgSDK - 激励视频 - 加载成功");
#endif
    ADJgSDKExtInfo *extInfo = [rewardvodAd adjg_extInfo];
    _bidPrice = extInfo.ecpm.floatValue;
    if ([self.containerDelegate respondsToSelector:@selector(jgsdkContainer_jgsdkRewardVodAdDidLoad:withPrice:)]) {
        [self.containerDelegate jgsdkContainer_jgsdkRewardVodAdDidLoad:self withPrice:_bidPrice];
    }
}

/**
 *  开屏广告请求失败
 */
- (void)adjg_rewardvodAdFailToLoad:(nonnull ADJgSDKRewardvodAd *)rewardvodAd errorModel:(nonnull ADJgAdapterErrorDefine *)errorModel {
    if ([self.containerDelegate respondsToSelector:@selector(jgsdkContainer_jgsdkRewardVodAdFailLoadError:)]) {
        [self.containerDelegate jgsdkContainer_jgsdkRewardVodAdFailLoadError:nil];
    }
}


@end
